package com.git.mark.dao;

import java.sql.CallableStatement;
import java.sql.SQLException;

public class MarkProcedure extends MarkBaseDao{

	
	public void getMarkProcedure() {
		
		conn = super.getCogdbConnection();
		try {
			String spName = "{call sp_add_emp1(?,?,?,?)}";
			CallableStatement cstmt = conn.prepareCall(spName);
			cstmt.setInt(1, 3);
			cstmt.setString(4, "wwww");
			cstmt.setInt(3, 2);  
			cstmt.setString(5, "qwqwq");  
			cstmt.executeUpdate();  
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
	
	public void getEmp(){
	
		conn=super.getCogdbConnection();
		  
		String spName="{call sp_add_emp2(?,?,?,?,?)}";  
		CallableStatement cstmt;
		try {
			cstmt = conn.prepareCall(spName);
			cstmt.setInt(1,1111);  
			cstmt.setString(2, "qqqq");  
			cstmt.setInt(3, 50);  
			cstmt.setString(4, "pppp");  
			cstmt.registerOutParameter(5, java.sql.Types.INTEGER);  
			cstmt.executeUpdate();  
			int i = cstmt.getInt(5);  
			System.out.println(i);  
			cstmt.close();  
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			super.close();
		}  
	
	}
	
	public void getDept(){
		conn=super.getCogdbConnection();
		  try {
				String spName="{call sp_add_emp2(?,?,?,?,?)}";  
				CallableStatement cstmt=conn.prepareCall(spName);  
				cstmt.setInt(1,8);  
				cstmt.setString(2, "admintest");  
				cstmt.setInt(3, 7);  
				cstmt.setString(4, "bumen");  
				cstmt.registerOutParameter(5, java.sql.Types.INTEGER);  
				cstmt.executeUpdate();  
				int i = cstmt.getInt(5);  
				System.out.println(i);  
				cstmt.close();	
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			super.close();
		}
  
	}
	
	public static void main(String[] args) {
		MarkProcedure mp = new MarkProcedure();
		mp.getDept();
 
	}
	
}
